package com.jiyun.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiyun.entity.Book;
import com.jiyun.mapper.BookMapper;
import com.jiyun.service.IBookService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 聪哥哥
 * @since 2023-04-19
 */
@Service
public class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements IBookService {

    @Autowired
    BookMapper bookMapper;

    @Override
    public Page<Book> findPage(Page<Book> bookPage, Book book) {
        LambdaQueryWrapper<Book> qw = new LambdaQueryWrapper<>();
        qw.like(StringUtils.isNotBlank(book.getName()),Book::getName,book.getName());
        qw.like(StringUtils.isNotBlank(book.getAuthor()),Book::getAuthor,book.getAuthor());
        qw.like(StringUtils.isNotBlank(book.getPress()),Book::getPress,book.getPress());
        bookMapper.selectPage(bookPage,qw);
        return bookPage;
    }
}
